class Solution:
	# @param {integer} n
	# @return {boolean}
	def isHappy(self, n):
		if n == 0:
			return False
		while n > 9:
			n = sum([int(i)*int(i) for i in list(str(n))])
		return n in [1,7]

	def eee(self,n):
		ans = [n]
		for i in xrange(20):
			n = sum([int(i)*int(i) for i in list(str(n))])
			ans.append(n)
		print ans

if __name__ == '__main__':
	so = Solution()
	print so.eee(8)
